/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.integrator;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Ed_Carlos
 */
public class User {

   public Connection conectarBD(){
       Connection conn = null;
       try{
        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
         Class.forName("oracle.jdbc.driver.OracleDriver");

              return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
        
   }catch (Exception e){  }
   return conn;}

    public String nome = "";
    public boolean result = false;

    public boolean verificarUsuario(String login, String senha) {
        String sql = "";
        Connection conn = conectarBD();
        
        sql += "select nome from usuarios ";
        sql +="where login = " + "'" + login + "'";
        sql += " and senha = " + "'" + senha + "';";
        try {
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(sql);
            if (rs.next()) {
                result = true;
                nome = rs.getString(nome);
            }
        } catch (Exception e) {
        }
        return result;
    }
}
